package com.yangguang.huahui.mvp.presenter;

import com.google.gson.Gson;
import com.yangguang.huahui.entity.Upload;
import com.yangguang.huahui.mvp.model.UploadModel;
import com.yangguang.huahui.mvp.view.UploadView;
import com.yangguang.huahui.rx.RxManager;
import com.yangguang.huahui.rx.RxSubscriber;
import com.yangguang.huahui.utils.LogUtil;

import java.io.File;
import java.io.IOException;
import java.util.List;

import okhttp3.ResponseBody;

/**
 * Created by Administrator on 2017/3/8.
 */

public class UploadPresenter extends BasePresenter<UploadView>{
    UploadModel model;

    public UploadPresenter() {
        model = new UploadModel();
    }
    public void uploadFile(List<String> pathList){
        mSubscription = RxManager.getInstance().doSubscribe(model.uploadFile(pathList), new RxSubscriber<ResponseBody>(false) {
            @Override
            protected void _onNext(ResponseBody responseBody) {
                try {
                    String result = responseBody.string();
                    LogUtil.e(result, true);
//                    mView.onSuccess(new Gson().fromJson(result, Upload.class));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            protected void _onError() {
//                mView.onError();
            }
        });
    }
}
